package dao;

import entity.User;
import utils.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class userDao  {
    public int find(User a){
        int num=0;
        String sql="select * from Userinfo\n" +
                " where [UID] =? and Upassword = ? ";
        Connection conn=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        try {
            conn= DBUtil.getConnection();
            ps=conn.prepareStatement(sql);
            ps.setString(1,a.getuName());
            ps.setString(2,a.getuPassWord());
            rs= ps.executeQuery();
            if (rs.next()){
             num=rs.getInt(1);

            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return num;
    }
}
